package com.library.weidget.wheel.wheel.adapter;



/**
 * 数字滚轮适配器
 * 
 * @author wangzengyang@gmail.com
 * @since 2013-12-26
 */
public class ArrayWheelAdapter3 extends WheelAdapter {
    private int startNumber;
    private int endNumber;

    String[] data;

    public ArrayWheelAdapter3(String[] data) {
        this.data=data;
        this.startNumber = 0;
        this.endNumber = data.length;
    }

    public void setData(String[] data){
        this.data=data;
        this.startNumber = 0;
        this.endNumber = data.length;

        notifyChanged();
    }

    @Override
    public int getCount() {
        return endNumber - startNumber;
    }

    @Override
    public String getItem(int index) {
        return data[startNumber+index];
    }
    @Override
    public int getValue(int index) {
        return startNumber+index;
    }

    /**
     * 获取当前起始数字
     * 
     * @return
     */
    @Override
    public int getStartValue() {
        return this.startNumber;
    }

    /**
     * 获取当前结束数字
     * 
     * @return
     */
    @Override
    public int getEndValue() {
        return this.endNumber;
    }

    /**
     * 获取数字间隔
     * 
     * @return
     */
    @Override
    public int getInterval() {
        return 1;
    }

    @Override
    public int getValueIndex(int value) {
        return value-startNumber;
    }

    @Override
    public void setStartValue(int value) {
        this.startNumber = value;
    }

}
